#coding=utf-8
from django.db import models

# Create your models here.
class IP(models.Model):
	'''IP表'''
	ip = models.IPAddressField(unique=True)
	port = models.CharField(max_length=10)
	user = models.CharField(max_length=50)
	passwd = models.CharField(max_length=100)
	protocol_type = models.CharField(max_length=50)
	hostname = models.CharField(max_length=50,blank=True)
	system = models.CharField(max_length=50,blank=True)
	server_models = models.CharField(max_length=50,blank=True)
	cpu = models.CharField(max_length=50,blank=True)
	cpumun = models.CharField(max_length=50,blank=True)
	hmem = models.CharField(max_length=50,blank=True)
	vmem = models.CharField(max_length=50,blank=True)
	disk = models.CharField(max_length=50,blank=True)
	group = models.CharField(max_length=50,blank=True)
	alias = models.CharField(max_length=50,blank=True)
	
	def __unicode__(self):
		return self.ip


class auth_method(models.Model):
	'''SSH协议表'''
	protocol = models.CharField(max_length=20)
	def __unicode__(self):
		return self.protocol

class IpGroup(models.Model):
	'''IP分组表'''
	group_name = models.CharField(max_length=30,unique=True)
	def __unicode__(self):
		return self.group_name
	
class AddServer(models.Model):
	'''服务安装表'''
	sname = models.CharField(max_length=100)
	spath = models.CharField(max_length=100)
	def __unicode__(self):
		return self.sname

class MServer(models.Model):
	'''服务管理表'''
	Mname = models.CharField(max_length=100)
	Mstart = models.CharField(max_length=200)
	Mrestart = models.CharField(max_length=200)
	Mstop = models.CharField(max_length=200)
	def __unicode__(self):
		return self.Mname

class Codeserver(models.Model):
	ip = models.IPAddressField(unique=True)
	backuppath = models.CharField(max_length=100)
	backdir = models.CharField(max_length=100) 
	path = models.CharField(max_length=100)
	def __unicode__(self):
		return self.ip

class User(models.Model):
	user = models.IPAddressField(unique=True)
	passwd = models.CharField(max_length=100)
	name = models.CharField(max_length=100,unique=True)
	post = models.CharField(max_length=100)
	phone = models.CharField(max_length=100)
	email = models.EmailField(max_length=100)
	qq = models.CharField(max_length=100)
	permissions  = models.CharField(max_length=10)
	def __unicode__(self):
		return self.user

class Task(models.Model):
	task_name = models.CharField(max_length=100)
	from_name = models.CharField(max_length=100)
	to_name = models.CharField(max_length=100)
	content = models.TextField(max_length=5000)
	now_time = models.DateTimeField(auto_now_add=True)
	completion_time = models.DateTimeField()
	urgent_status = models.CharField(max_length=2)
	task_status = models.CharField(max_length=2,default="0")
	def __unicode__(self):
		return self.task_name

class TaskComments(models.Model):
	taskid = models.CharField(max_length=10)
	fromname = models.CharField(max_length=20)
	toname = models.CharField(max_length=20,blank=True)
	content = models.TextField(max_length=5000)
	now_time = models.DateTimeField(auto_now_add=True)
	def __unicode__(self):
		return self.taskid

class Message(models.Model):
	taskid = models.CharField(max_length=10)
	fromname = models.CharField(max_length=20)
	toname = models.CharField(max_length=20)
	title = models.CharField(max_length=100)
	content = models.TextField(max_length=5000,blank=True)
	status = models.CharField(max_length=2,default="0")
	now_time = models.DateTimeField(auto_now_add=True)
	def __unicode__(self):
		return self.title
	
class Config(models.Model):
	mailsmtp = models.CharField(max_length=100)
	mailuser = models.CharField(max_length=50)
	mailpass = models.CharField(max_length=100)
	mailfrom = models.CharField(max_length=100)

class Department(models.Model):
	name = models.CharField(max_length=50)
	def __unicode__(self):
		return self.name

class Usergroup(models.Model):
	name = models.CharField(max_length=50)
	def __unicode__(self):
		return self.name
	

